package sentinelservice.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sentinelservice.blockhandler.HelloControllerBlockHandler;
import vo.ResponseResult;

@RestController
public class HelloController {

    public ResponseResult helloBlockHandler(BlockException e){
        System.out.println("HelloController.helloBlockHandler()");
        return ResponseResult.fail("helloBlockHandler处理异常",e);
    }

//    @SentinelResource(value = "hello",blockHandler = "helloBlockHandler")
    @SentinelResource(value = "hello",blockHandlerClass = HelloControllerBlockHandler.class,blockHandler = "blockHandler")
    @RequestMapping("/hello")
    public ResponseResult hello(){
        System.out.println("HelloController.hello()");
        return ResponseResult.success();
    }
}